#include "Core.h"
#include "RenderManager.h"
#include "Language\LanguageManager.h"
#include "Font\FontManager.h"
#include "InputManager.h"


CCore::CCore()
: m_pRenderManager(NULL)
, m_pFontManager(NULL)
, m_pLanguageManager(NULL)
, m_pInputManager(NULL)
{}


CCore::~CCore()
{
	DeInit();
}

void CCore::Init(HWND hWnd, const SEngineInitParams& params)
{
	//Init Graphics:
	m_pRenderManager = new CRenderManager();
	m_pRenderManager->Init(hWnd, params);

	//Init LanguageManager
	m_pLanguageManager = new CLanguageManager();
	assert(m_pLanguageManager);
	for(int i=0; i < (int) params.m_LaguagesXML.size(); ++i)
	{
		m_pLanguageManager->SetXmlFile(params.m_LaguagesXML[i]);
	}
	m_pLanguageManager->LoadXMLs();
	m_pLanguageManager->SetCurrentLanguage(params.m_DefaultLanguage);

	//Init FontManager
	m_pFontManager = new CFontManager();
	assert(m_pFontManager);
	m_pFontManager->Init(m_pRenderManager);
	m_pFontManager->LoadTTFs(params.m_FontsXML);
	
	//Init Sounds:

	//Init PhysX:

	//Init Input:
	m_pInputManager = new CInputManager();
	assert(m_pInputManager);
	m_pInputManager->Init(hWnd, params.m_ScreenResolution, params.m_bExclusiveModeinMouse);
}

void CCore::DeInit()
{
	CHECKED_DELETE(m_pRenderManager);
	CHECKED_DELETE(m_pFontManager);
	CHECKED_DELETE(m_pLanguageManager);
	CHECKED_DELETE(m_pInputManager);
}

void CCore::Update(float dt)
{
	m_pInputManager->Update();
	m_pRenderManager->Update(dt);
}

void CCore::Render()
{
	m_pRenderManager->Render();
}